<template>
	<view>
		<uniSearchBar></uniSearchBar>

		<view class="page-section-spacing">
			<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
				<swiper-item v-for="item in swiperList" :key='index'>
					<image :src="item.image_src" mode=""></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="more">
			<view class="item" v-for="(item,index) in catitems" :key='index'>
				<image :src="item.image_src" mode=""></image>
			</view>

		</view>

		<view class="style" v-for="(item,index) in floordata" :key='index'>
			<view class="title">
				<image :src="item.floor_title.image_src" mode=""></image>
				<!-- {{item.floor_title.name}} -->
			</view>
			<view class="wear">
				<view class="left">
					<image :src="item.product_list[0].image_src" mode=""></image>
				</view>
				<view class="right" >
					<view class="item" v-for="(items,index) in item.product_list.slice(1)" :key='index'>
						<image :src="items.image_src" mode=""></image>
					</view>
					<!-- <view class="item">

					</view>
					<view class="item">

					</view>
					<view class="item">

					</view> -->
				</view>
			</view>
		</view>

	</view>


</template>

<script>
	import uniSearchBar from '@/components/search/search.vue'
	export default {
		components: {
			uniSearchBar
		},
		data() {
			return {

				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				swiperList: [],
				catitems: [],
				floordata: []
			}
		},
		onLoad() {
			this.getWiperdata(),
				this.getCatitems(),
				this.getFloordata()
		},
		methods: {
			getFloordata() {
				uni.request({
					url: "https://www.uinav.com/api/public/v1/home/floordata",
					success: (res) => {

						// 获取数据
						this.floordata = res.data.message
						console.log(res.data.message)

						// 优化
						// 结构一次性拿到message meta

					}
				})
			},
			getCatitems() {
				uni.request({
					url: "https://www.uinav.com/api/public/v1/home/catitems",
					success: (res) => {

						// 获取数据
						// this.swiperList = res.data.message
						// console.log(res.data.message)
						this.catitems = res.data.message
						// 优化
						// 结构一次性拿到message meta

					}
				})
			},
			getWiperdata() {
				uni.request({
					url: "https://www.uinav.com/api/public/v1/home/swiperdata",
					success: (res) => {

						// 获取数据
						// this.swiperList = res.data.message
						// console.log(res.data.message)

						// 优化
						// 结构一次性拿到message meta
						let {
							message,
							meta
						} = res.data
						if (meta.status === 200) {
							this.swiperList = message
						}
					}
				})
			}

		}
	}
</script>

<style lang='less'>
	.search_bar {
		background: #eb4450;
		padding: 20rpx 16rpx;

		.inner {
			height: 60rpx;
			background-color: #FFFFFF;
			border-radius: 8rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			text {
				color: #666;
				font-size: 24rpx;
			}
		}
	}


	.swiper {
		width: 100%;
		height: 180px;

		image {
			width: 100%;
			
		}
	}

	.more {
		margin: 40rpx 0;
		display: flex;
		justify-content: space-around;

		.item {
			width: 128rpx;
			height: 140rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.style {


		.title {
			font-size: 16rpx;
			background-color: #f5f5f5;
			padding: 10rpx 0;
			image {
				width: 100%;
				height: 88rpx;
			}
		}

		.wear {
			display: flex;
/* 			background-color: #007AFF; */
			width: 100%;
			height: 400rpx;

			.left {
				flex: 1;
				height: 100%;
				background-color: red;
				image {
					width: 100%;
					height: 100%;
				}
			}

			.right {
				flex: 2;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-around;

				.item {
					width: 48%;
					height: 48%;
					/* background-color: #4CD964; */
					
					 image {
						 width: 100%;
						 height: 100%;
					 }
				}

			}
		}
	}
</style>
